package com.bonc.situation.controller;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bonc.situation.api.DataClient;
import com.bonc.situation.service.TestService;
import com.bonc.situation.vo.TestBean;
import com.bonc.situation.vo.TestHBaseBean;

@RestController
@RequestMapping("/agent")
public class TestController {
	private final static Logger logger = LoggerFactory.getLogger(TestController.class);
	@Autowired
	private TestService service;
	@Autowired
	private DataClient dataClient;
	@GetMapping("/getById/{id}")
	public Object getReportByCityId(@PathVariable("id")String id,Model model){
		List<TestHBaseBean> list = new ArrayList<TestHBaseBean>();
		try {
			list = dataClient.getList();
		} catch (Exception e) {
			logger.error("获取Hbase信息异常",e);
			throw new RuntimeException("获取Hbase数据异常",e);
		}
		TestBean bean = service.getDataById(id);
		if(bean != null) {
			bean.setList(list);
		}
		return bean;
		
	}
}
